package com.jiazhong.Text;


import com.jiazhong.service.AccountService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TransactionTest {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        AccountService accountService = context.getBean(AccountService.class);

        try {
            accountService.transfer("1", "2", 20.0);
            System.out.println("转账成功！");
        } catch (Exception e) {
            System.out.println("转账失败：" + e.getMessage()); // 捕获事务回滚后的异常
        }
    }
}
